//******************************************************************************
// TITLE:                      	Using Classes + Inheritance 
// FILENAME:                   	TelephoneNumber.cpp
// PREPARED FOR:               	CS215 Section CS13-02
// PROGRAMMER(S):              	Eric (Fox) Crowell
// DEVELOPMENT DATE:           	< 12/02/13 >
// COMPILER USED:      			Microsoft Visual Studio Ultimate 2013
// TARGET PLATFORM:         	Windows 8 x64
//================================================================

#include "TelephoneNumber.h"

TelephoneNumber::TelephoneNumber(){
	cout << "In Telephone Number Default Constructor.\n";
	this->NPA = "555";
	this->NXX = "555";
	this->Line = "5555";
}

TelephoneNumber::TelephoneNumber(const string &inNPA, const string &inNXX, const string &inLine){
	cout << "In Telephone Number Three Parameter Constructor.\n";

	if (inNPA.length() == 3){ this->NPA = inNPA; }
	else { this->NPA = "555"; }

	if (inNXX.length() == 3){ this->NXX = inNXX; }
	else { this->NXX = "555"; }

	if (inLine.length() == 4){ this->Line = inLine; }
	else { this->Line = "5555"; }
}

TelephoneNumber::~TelephoneNumber(){
	cout << "In Telephone Number Destructor.\n";
}

// SETTERS
void TelephoneNumber::setNPA(const string &inNPA){
	if (inNPA.length() != 3 ){
		cout << "Failed to set NPA length. Must be exactly three characters in length.\n";
		return;
	}

	this->NPA = inNPA;
}

void TelephoneNumber::setNXX(const string &inNXX){
	if (inNXX.length() != 3){
		cout << "Failed to set NXX length. Must be exactly three characters in length.\n";
		return;
	}

	this->NXX = inNXX;
}

void TelephoneNumber::setLine(const string &inLine){
	if (inLine.length() != 4){
		cout << "Failed to set NXX length. Must be exactly four characters in length.\n";
		return;
	}

	this->Line = inLine;
}

// GETTERS
string TelephoneNumber::getNPA() const{
	return(this->NPA);
}

string TelephoneNumber::getNXX() const{
	return(this->NXX);
}

string TelephoneNumber::getLine() const{
	return(this->Line);
}

// Virtual Function (Needed to be virtual for Polymorphism)
void TelephoneNumber::PrintToStream(ostream &out){
	out << "Telephone Number: "
		<< this->NPA << "-" << this->NXX << "-" << this->Line << "\n";
}